package com.ubxtech.core.req;

import com.ubxtech.core.utils.StrPool;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

import jakarta.validation.Valid;
import jakarta.validation.constraints.NotNull;

/**
 * @author Victor.Xiao
 * @since 2022-01-14 11:19
 **/
@EqualsAndHashCode(callSuper = true)
@Data
@NoArgsConstructor
@Schema(title = "PageReq", description = "分页参数")
public class PageReq<T> extends Req {

    @Valid
    @NotNull(message = "查询对象不能为空")
    @Schema(title = "查询参数", required = true)
    private T params;

    @Schema(title = "页面大小", example = "10")
    private long size = 10;

    @Schema(title = "当前页", example = "1")
    private long current = 1;

    @Schema(title = "排序,默认createTime", allowableValues = "id,createTime,updateTime", example = "id")
    private String sortField = StrPool.FIELD_ID;

    @Schema(title = "排序规则, 默认desc", allowableValues = "desc,asc", example = "desc")
    private String order = "desc";

    public PageReq(long current, long size) {
        this.size = size;
        this.current = current;
    }


}
